/*
 * 
 * author: yeyi
 * date: 2017年10月7日
 */
package test.integer;

/**
 * 演示 Integer.reverse 功能：
 * 直接把二进制的位完全反过来
 * @author: yeyi
 * @date: 2017年10月7日
 */
public class IntegerReverse {
    public static void main(String[] args) {

        int i = 123;
        System.out.println("Number = " + i);
       
        /* returns the string representation of the unsigned integer value 
        represented by the argument in binary (base 2) */
        System.out.println("Binary = " + Integer.toBinaryString(i));

        // returns the number of one-bits 
        System.out.println("Number of one bits = " + Integer.bitCount(i)); 
     
        /*  returns the value obtained by reversing order of the bits in 
        the specified int value */ 
        Integer rev = Integer.reverse(i);
        System.out.println("After reversing = " + rev);
        System.out.println("After Binary = " + Integer.toBinaryString(rev));
      }
}
